<?php
/**
 * Created by PhpStorm.
 * User: wangan
 * Date: 2017/4/16
 * Time: 11:57
 */

namespace App\Http\Service;

use App\Models\Chapters;

class ChapterService{

    public static function createRootNode($arr_info){
       return Chapters::create($arr_info)->makeRoot();;
    }

    public static function createNode($int_pid, $arr_info){
        $obj_pNode = Chapters::find($int_pid);
        return Chapters::create($arr_info)
            ->makeChildOf($obj_pNode);
    }

    public static function getNodeInfo($int_id){
        return Chapters::find($int_id);
    }

    public static function updateNodeInfo($arr_info){
        $obj_pNode = Chapters::find($arr_info['id'])
            ->update($arr_info);
        return $obj_pNode;
    }

    public static function deleteNode($int_id){
        return  Chapters::find($int_id)->delete();
    }

}